import Vue from 'vue'
import Router from 'vue-router'
import home from '@/components/Home'
import category from '@/components/category'
import shoppingcar from '@/components/shoppingcar'
import user from '@/components/user/index'
import collectList from '@/components/user/collectList'
import addressList from '@/components/user/addressList'
import editAddress from '@/components/user/editAddress'
import nounRecord from '@/components/user/nounRecord'

// 限时秒杀
import assemble from '@/components/assemble/assemble'
// 低价火拼
import teamList from '@/components/assemble/teamList'
// 积分专区
import nounList from '@/components/assemble/nounList'
// 商品详情
import detail from '@/components/goods/detail'
// 限时秒杀商品详情
import skDetail from '@/components/goods/skDetail'
// 搜索
import search from '@/components/index/search'
// 绑定手机号
import mobile from '@/components/auth/mobile'
// 订单
import order from '@/components/order/order'
// 订单详情
import orderDetail from '@/components/order/orderDetail'
// 订单列表
import orderList from '@/components/order/orderList'
// 商品列表
import goodsList from '@/components/goods/goodsList'
// 拼团详情
import teamDetail from '@/components/goods/teamDetail'
// 积分详情
import nounDetail from '@/components/goods/nounDetail'
// 积分订单
import orderNoun from '@/components/order/orderNoun'
// 积分支付成功
import paySuccess from '@/components/shopping/paySuccess'
// 积分支付成功
import paySuccess2 from '@/components/shopping/paySuccess2'
// 积分支付成功
import paySuccess3 from '@/components/shopping/paySuccess3'

// 重载当前页
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}

Vue.use(Router)

export default new Router({
  routes: [{
      // 首页展示
      path: '/',
      name: 'home',
      component: home
    },{
      // 分类
      path: '/category',
      name: 'category',
      component: category
    },{
      // 购物车
      path: '/shoppingcar',
      name: 'shoppingcar',
      component: shoppingcar
    },{
      // 我的
      path: '/user',
      name: 'user',
      component: user
    },{
      // 绑定手机号
      path: '/auth/mobile',
      name: 'mobile',
      component: mobile
    },{
      // 收藏
      path: '/user/collectList',
      name: 'collectList',
      component: collectList
    },{
      // 新增收货地址
      path: '/user/addressList',
      name: 'addressList',
      component: addressList
    },{
      // 编辑收货地址
      path: '/user/editAddress',
      name: 'editAddress',
      component: editAddress
    },{
      // 积分记录
      path: '/user/nounRecord',
      name: 'nounRecord',
      component: nounRecord
    },{
      // 搜索
      path: '/index/search',
      name: 'search',
      component: search
    },{
      // 商品详情
      path: '/goods/detail',
      name: 'detail',
      component: detail
    },{
      // 限时秒杀商品详情
      path: '/goods/skDetail',
      name: 'skDetail',
      component: skDetail
    },{
      // 限时秒杀==秒杀专区
      path: '/assemble/assemble',
      name: 'assemble',
      component: assemble
    },{
      // 低价火拼
      path: '/assemble/teamList',
      name: 'teamList',
      component: teamList
    },{
      // 积分专区
      path: '/assemble/nounList',
      name: 'nounList',
      component: nounList
    },{
      // 订单
      path: '/order/order',
      name: 'order',
      component: order
    },{
      // 订单详情
      path: '/order/orderDetail',
      name: 'orderDetail',
      component: orderDetail
    },{
      // 订单列表
      path: '/order/orderList',
      name: 'orderList',
      component: orderList
    },{
      // 产品列表
      path: '/goods/goodsList',
      name: 'goodsList',
      component: goodsList
    },{
      // 团购详情
      path: '/goods/teamDetail',
      name: 'teamDetail',
      component: teamDetail
    },{
      // 积分详情
      path: '/goods/nounDetail',
      name: 'nounDetail',
      component: nounDetail
    },{
      // 积分订单
      path: '/order/orderNoun',
      name: 'orderNoun',
      component: orderNoun
    },{
      // 积分支付成功
      path: '/shopping/paySuccess',
      name: 'paySuccess',
      component: paySuccess
    },{
      // 积分支付成功
      path: '/shopping/paySuccess2',
      name: 'paySuccess2',
      component: paySuccess2
    },{
      // 积分支付成功
      path: '/shopping/paySuccess3',
      name: 'paySuccess3',
      component: paySuccess3
    }
  ]
})
